

<form id="myForm" action="<?php echo $current?>updatedata" class="form-horizontal" role="form">

	<?
	if($dataList->isMain=="Y"){
		echo $genhtml -> getTextBox("หัวข้อ", "title");
	}else{
		echo $genhtml->getHidden("title","title");
	}
	echo $genhtml->getHidden("fID","fID");
	if($isAdmin){
		$dataCombo[]  =array("forumType"=>"General");
		$dataCombo[]  =array("forumType"=>"Hot");
		$dataCombo[]  =array("forumType"=>"New");
		echo $genhtml->getComboBox("ประเภท","forumType",$dataCombo,"forumType","forumType");
	}
	echo $genhtml->getTextArea("ข้อความ","message");
	
	if($isAdmin){	
		echo $genhtml->getCheckBox("ปักหมุด","isPin","Y");
	}
	
	echo '<div id="containImage">';
	if($dataList->image!=""){
	?>
		<img src="<?php echo site_url() ?>file_upload/<?php echo $dataList->image?>" />
	<?
	}
	echo '<input type="hidden" id="image" name="image" value="'.$dataList->image.'" />';
	echo '</div>';
	echo $genhtml->getUpload();
	echo $genhtml -> getButton("Submit", "UpdateData", "Update", "primary");
	
	?>
</form>


<script src="<?php echo $pjs?>vendor/jquery.ui.widget.js"></script>
<script src="<?php echo $pjs?>jquery.iframe-transport.js"></script>

<script src="<?php echo $pjs?>jquery.fileupload.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="<?php echo $pcss?>jquery.fileupload.css" rel="stylesheet">

<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = '<?php echo $current.'uploadImage'?>';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
        	if(data.result.flag){
        		var size = $('#containImage').find('img').size();
        		if(size==0){
        			$('#containImage').append('<img src="" />');
        		}
        		$('#image').val(data.result.message);
        		$('#containImage img').attr("src",'<?php echo site_url() ?>file_upload/'+data.result.message);
        	}else{
        		alert("error on upload")
        	}
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>
<script type="text/javascript">
	$(document).ready(function() {
		
		initNormalForm(function(data){
			
			if(data.flag=="true"){
				var isMain = '<?php echo $dataList->isMain?>';
				if(isMain=="Y"){
					window.location.href = baseUrl+"forum/view/<?php echo $dataList->fID?>";
				}else{
					window.location.href = baseUrl+"forum/view/<?php echo $dataList->parent?>";
				}
			}else{
				alert(data.message);
			}
		})
	})
</script>
